﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="Attributesfamilies.aspx.cs" Inherits="ColorApplication.color.Attributesfamilies" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2>Attributes families
    </h2>
    <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
        <ProgressTemplate>
            <div id="modalPage" runat="server" class="modalPage">
                <div class="modalBackground">
                </div>
                <div class="modalContainer">
                    <div class="modal">
                        <table>
                            <tr>
                                <td align="center">
                                    <div style="background-color: White; border-radius: 5px; color: black; height: 47px;
                                        padding-top: 5px;">
                                        Please Wait...
                                        <br />
                                        <img src="../Images/preloader.gif" />
                                    </div>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
            </div>
        </ProgressTemplate>
    </asp:UpdateProgress>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:Label ID="ErrorLabel" runat="server" CssClass="failureNotification"></asp:Label>
            <asp:Label ID="SuccesLabel" runat="server" CssClass="successNotification"></asp:Label>
            <asp:DetailsView ID="AttributefamiliesDetailsView" runat="server" Height="50px" Width="50%"
                AutoGenerateRows="False" DataKeyNames="Id" DataSourceID="AttributefamiliesSqlDataSource"
                DefaultMode="Insert" OnItemInserted="AttributefamiliesDetailsView_ItemInserted"
                OnItemUpdated="AttributefamiliesDetailsView_ItemUpdated" OnItemInserting="AttributefamiliesDetailsView_ItemInserting"
                OnItemUpdating="AttributefamiliesDetailsView_ItemUpdating">
                <Fields>
                    <asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="False" ReadOnly="True"
                        SortExpression="Id" Visible="False" />
                    <asp:TemplateField HeaderText="Description" SortExpression="Description">
                        <EditItemTemplate>
                            <asp:TextBox ID="EditDescriptionTextBox" runat="server" Text='<%# Bind("Description") %>'></asp:TextBox>
                            <asp:RequiredFieldValidator ID="EditDescriptionRequiredFieldValidator" runat="server"
                                ControlToValidate="EditDescriptionTextBox" CssClass="failureNotification" Display="Dynamic"
                                ErrorMessage="Description is required."></asp:RequiredFieldValidator>
                        </EditItemTemplate>
                        <InsertItemTemplate>
                            <asp:TextBox ID="InsertDescriptionTextBox" runat="server" Text='<%# Bind("Description") %>'></asp:TextBox>
                            <asp:RequiredFieldValidator ID="InsertDescriptionRequiredFieldValidator" runat="server"
                                ControlToValidate="InsertDescriptionTextBox" CssClass="failureNotification" Display="Dynamic"
                                ErrorMessage="Description is required."></asp:RequiredFieldValidator>
                        </InsertItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label1" runat="server" Text='<%# Bind("Description") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:CommandField ShowEditButton="True" ShowInsertButton="True" />
                </Fields>
            </asp:DetailsView>
            <asp:SqlDataSource ID="AttributefamiliesSqlDataSource" runat="server" CancelSelectOnNullParameter="False"
                ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" InsertCommand="InsertAttributesfamiliesInsert"
                InsertCommandType="StoredProcedure" SelectCommand="GetAttributesfamiliesSelect"
                SelectCommandType="StoredProcedure" UpdateCommand="UpdateAttributesfamiliesUpdate"
                UpdateCommandType="StoredProcedure">
                <InsertParameters>
                    <asp:Parameter Name="Description" Type="String" />
                </InsertParameters>
                <SelectParameters>
                    <asp:ControlParameter ControlID="AttributefamiliesGridView" Name="Id" PropertyName="SelectedValue"
                        Type="Int32" />
                </SelectParameters>
                <UpdateParameters>
                    <asp:Parameter Name="Id" Type="Int32" />
                    <asp:Parameter Name="Description" Type="String" />
                </UpdateParameters>
            </asp:SqlDataSource>
            <br />
            <br />
            <table>
                <tr>
                    <td>Search By Description :
                    </td>
                    <td>
                        <asp:TextBox ID="SearchDescriptionTextBox" AutoPostBack="true" runat="server"></asp:TextBox>
                    </td>
                </tr>
            </table>
            <br />
            <asp:GridView ID="AttributefamiliesGridView" runat="server" AutoGenerateColumns="False"
                DataKeyNames="Id" DataSourceID="AttributeFamiliesGridSqlDataSource" OnRowDataBound="AttributefamiliesGridView_RowDataBound"
                OnSelectedIndexChanged="AttributefamiliesGridView_SelectedIndexChanged" Width="50%"
                OnRowDeleting="AttributefamiliesGridView_RowDeleting" AllowSorting="true">
                <Columns>
                    <asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="False" ReadOnly="True"
                        SortExpression="Id" Visible="False" />
                    <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="description" />
                    <asp:CommandField SelectText="Edit" ShowSelectButton="True" />
                    <asp:TemplateField HeaderText="attributes">
                        <ItemTemplate>
                            <asp:HyperLink ID="AttributeHyperLink" runat="server" NavigateUrl='<%# "~/color/AttributeXAttributefamilies.aspx?AttributeFamiliesId=" +Eval("Id") %>'
                                Text="attributes"></asp:HyperLink>
                        </ItemTemplate>
                        <ItemStyle HorizontalAlign="Center" />
                    </asp:TemplateField>
                    <asp:TemplateField ShowHeader="False">
                        <ItemTemplate>
                            <asp:LinkButton ID="DeleteLinkButton" runat="server" CausesValidation="False" CommandName="Delete"
                                Text="Delete"></asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
            <asp:SqlDataSource ID="AttributeFamiliesGridSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
                DeleteCommand="DeleteAttributesfamiliesDelete" DeleteCommandType="StoredProcedure"
                SelectCommand="GetSearchByAttributesfamiliesSelect" SelectCommandType="StoredProcedure"
                CancelSelectOnNullParameter="False">
                <DeleteParameters>
                    <asp:Parameter Name="Id" Type="Int32" />
                </DeleteParameters>
                <SelectParameters>
                    <asp:ControlParameter ControlID="SearchDescriptionTextBox" PropertyName="Text" Name="Description"
                        Type="String" />
                </SelectParameters>
            </asp:SqlDataSource>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
